<?php
require 'lib/init.php';
if(empty($_POST)){
    $cats=mGetAll('select * from cat;');
    $art=mGetRow("select * from article where art_id=$_GET[id];");
    require 'view/admin/artedit.html';
}else{
    if(empty(trim($_POST['title']))){
        echo '标题不能为空';
        header('refresh:2;url=artedit.php');
        exit();
    }
    if(empty(trim($_POST['content']))){
        echo '内容不能为空';
        header('refresh:2;url=artedit.php');
        exit();
    }
    mQuery("set names utf8");
    $_POST['lastup']=time();
    $res=mExec('article',$_POST,'update',"art_id=$_GET[id]");
    $res?success('文章编辑成功'):error('文章编辑失败');
}
